// @ts-check
// 默认启用vscode提供的ts强类型检查

// 默认导入一揽子vue2.7内常用的组合式api。 prettier忽略本行。
// prettier-ignore
import { defineComponent, ref, computed, watch, nextTick, onMounted } from "vue";

// 默认导入来自lodash-es提供的常用工具。 prettier忽略本行。
// prettier-ignore
import { isArray, isUndefined, isString, isNumber, isNil, isEqual, toString, merge, cloneDeep } from "lodash-es";

import store from "@/store/index.js";
import settings from "@/settings.js";

/**
 * use-layout-conf
 * @author 技术运维中心 阮中楠
 * @description
 */
export function useLayoutConf() {
  /** @type { import("./types/use-layout-conf").DefaultLayoutType } */
  const defLayoutType = settings.layout.layoutType;

  /** @type { import("./types/use-layout-conf").LayoutTypeConf } */
  const errorLayoutTypeConf = {
    label: "警告！ 没有找到正确的值。这里使用默认布局。",
    value: defLayoutType,
  };

  /** @type { import("./types/use-layout-conf").LayoutTypeConf[] } */
  const layoutTypeConfs = [
    {
      label: "单侧边栏",
      value: "single-sidebar",
    },

    {
      label: "顶部导航栏+侧边栏",
      value: "header-sidebar",
    },

    // TODO: 没空实现该布局 故暂时隐藏该配置选项
    // {
    //   label: "双顶部导航栏+侧边栏",
    //   value: "double-header-sidebar",
    // },
  ];

  /** @type { import("./types/use-layout-conf").GetConf } */
  function getConf(value) {
    return (
      layoutTypeConfs.find((conf) => conf.value === value) ??
      errorLayoutTypeConf
    );
  }

  /** @type { import("./types/use-layout-conf").GetCurrentLayoutType } */
  function getCurrentLayoutType() {
    // console.log(store.state.setting.layoutType)
    return store.state.setting.layoutType ?? defLayoutType;
  }

  /** @type { import("./types/use-layout-conf").IsSingleSidebar } */
  function isSingleSidebar(value) {
    return value === "single-sidebar";
  }

  /** @type { import("./types/use-layout-conf").IsHeaderSidebar } */
  function isHeaderSidebar(value) {
    return value === "header-sidebar";
  }

  /** @type { import("./types/use-layout-conf").IsDoubleHeaderSidebar } */
  function isDoubleHeaderSidebar(value) {
    return value === "double-header-sidebar";
  }

  return {
    layoutTypeConfs,
    getConf,
    getCurrentLayoutType,

    isSingleSidebar,
    isHeaderSidebar,
    isDoubleHeaderSidebar,
  };
}
